#include <stdlib.h>
#include <stdio.h>

#define M 4
#define N 5

	int main()
{
	int a[M][N] = {{1,2,3,4},{5,6,7,8},{9,10,11,12}};
	int i,j;

	for(i = 0;i < M-1;i++)
	{
		for(j = 0;j < N-1;j++)
		{
			a[i][4] += a[i][j];
			a[3][j] += a[i][j];
			a[3][4] += a[i][j];
		}
	}
	for(i = 0;i < M;i++)
	{
		for(j = 0;j < N;j++)
		{
			printf("%4d",a[i][j]);
		}
		printf("\n");
	}
	exit(0);
}
